@extends('layouts.app')

@section('title', '赠予饭卡')

@section('css-import')
<style type="text/css">
.form-input-control{
	margin-bottom: 20px;
}
.loadCardBackground{
	width: 350px;
	display: block;
	margin:15px;
}
.fancy-checkbox-re{
	display: inline-block;
}
.fancy-checkbox-paren{
	display: block;
    font-weight: normal;
}
</style>
@endsection

@section('content-fluid')

<div class="panel">
	<div class="panel-heading">
		<h3 class="panel-title">赠卡</h3>
	</div>
	<div class="panel-body">
		<form action="/card/gift/action" method="post" id="createIdPower">
			收卡人手机号
			<input type="text" name="tel" class="form-control" value="" autocomplete="off" placeholder="收卡人手机号">
			<br>
			赠卡理由
			<select class="form-control form-input-control" name="buy_type">
	      		<option value="3">合作赠予</option>
	      		<option value="4">助理点餐</option>
	      		<option value="5">测试需要</option>
	      		<option value="6">活动发放</option>
	      	</select>
			<br>
			选择饭卡
			<select class="form-control form-input-control" name="card_id">
				@foreach($cards as $k=>$v)
	      		<option value="{{$v->card_id}}">{{$v->card_name}}</option>
	      		@endforeach
	      	</select>
			<input type="hidden" name="admin_id" value="">
			<input type="hidden" name="bank_id" value="">
			<br><br>
			<div class="row">
				<div class="col-md-2">
					<button type="submit" class="btn btn-success btn-block">确认发卡</button>
				</div>
			</div>
		</form>
	</div>
</div>
@endsection

@section('js-import')
<script type="text/javascript" src="{{config('app.inlet_src')}}/a/js/design.js"></script>
@endsection

@section('js-write')
<script type="text/javascript">
	var CouponSendParam = {
	    'dataType':'json',
	    'beforeSubmit':CouponBefore,
	    'success':CouponResponse,
	    'error':toutiaoError,
	};
	function CouponBefore(formData, jqForm, options){
	    
	}
	function CouponResponse(response) {
	    if(response.success){
	        setTimeout(function(){
	            location.href = '/user-details?userid='+response.data.user_id;
	        },2000);
	        toastr.success(response.message+'.正在跳转用户主页');
	    }else{
	        toastr.error(response.message);
	    }
	}

	function toutiaoError(XMLHttpRequest, textStatus, errorThrown) {
		if(XMLHttpRequest.status==422){
			var RegError = XMLHttpRequest.responseJSON.errors;
			for(var o in RegError){
				for (var i = 0; i < RegError[o].length; i++) {
					toastr.error(RegError[o][i]);
				}
			}
		}
	}
	ajaxForm_('#createIdPower', CouponSendParam);
</script>
@endsection